package com.scrcu.cloud.wechat.home.endpoint.common.config;

import com.alipay.drm.client.DRMClient;
import com.alipay.drm.client.api.annotation.DAttribute;
import com.alipay.drm.client.api.annotation.DObject;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
/**
 * @auther: 刘思良
 * @date: 2024/08/09 14:58
 * @description:
 * @version: 1.0.0
 */



@Slf4j
@Component
@DObject(region = "demo",appName = "demo-home")
@ToString
public class DynamicConfig {

    @DAttribute
    private int minCacheNum;

    /**
     * 赋默认值
     */
    public DynamicConfig() {
        this.minCacheNum = 1000;
    }

    @PostConstruct
    public void init() {
        log.info("message before DynamicConfig init is:{}", this);
        DRMClient.getInstance().register(this);
        log.info("message after DynamicConfig init is:{}", this);
    }

    public int getMinCacheNum() {
        return minCacheNum;
    }

    public void setMinCacheNum(int minCacheNum) {
        this.minCacheNum = minCacheNum;
    }
}
